package com.xaicode.ctoroad.kafka;

import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;
import org.springframework.kafka.support.ProducerListener;
import org.springframework.stereotype.Component;

/**
 * 生产者消息推送回调
 *
 * @author Locker cjxia@isoftstone.com
 * @version 1.0
 */
@Slf4j
@Component
public class KafkaProducerCallback implements ProducerListener {

    @Override
    public void onSuccess(ProducerRecord producerRecord, RecordMetadata recordMetadata) {
        log.info("--- Message send success : " + producerRecord.toString());
    }

    @Override
    public void onError(ProducerRecord producerRecord, Exception exception) {
        log.info("--- Message send error : " + producerRecord.toString());
    }
}
